<?
    include "../common.php" ;
    $opt = $_POST['opt'] ; 
    $arr = [] ; 
    if( $opt === 'getBanner' ){
        $sql = "SELECT t.imgSrc FROM `transimg` AS t JOIN `ptype` AS pt ON t.typeId = pt.id WHERE is_banner = 0" ;
        $res = mysqli_query($link,$sql);
        while( $one = mysqli_fetch_assoc($res) ){
            $arr[] = $one ; 
        }
    }
    if( $opt == 'getTypeData' ){
        $sql = "SELECT * FROM `ptype` WHERE is_banner = 1" ;
        $res = mysqli_query($link,$sql);
        while( $one = mysqli_fetch_assoc($res) ){
            $arr[] = $one ; 
        }
    }
    if( $opt == 'getGoodsData' ){
        $typeId = $_POST['typeId'] ;
        $sql = "SELECT * FROM `products` WHERE typeid = {$typeId} AND is_delete = 1 ORDER BY id ASC LIMIT 0,10" ;
        $res = mysqli_query($link,$sql);
        while( $one = mysqli_fetch_assoc($res) ){
            $arr[] = $one ; 
        }
    }
    if( $opt == 'getTypeTransData' ){
        $typeId = $_POST['typeId'] ;
        $sql = "SELECT * FROM `transimg` WHERE typeId = {$typeId} AND is_delete = 1 ORDER BY id ASC" ;
        $res = mysqli_query($link,$sql);
        while( $one = mysqli_fetch_assoc($res) ){
            $arr[] = $one ;
        }
    }
    echo json_encode($arr);
?>